/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gestion;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author rocio
 */
@Entity
@Table(name = "factura", catalog = "lpd", schema = "")
@NamedQueries({@NamedQuery(name = "Factura.findAll", query = "SELECT f FROM Factura f"), @NamedQuery(name = "Factura.findByIDfactura", query = "SELECT f FROM Factura f WHERE f.iDfactura = :iDfactura"), @NamedQuery(name = "Factura.findByFecha", query = "SELECT f FROM Factura f WHERE f.fecha = :fecha"), @NamedQuery(name = "Factura.findByIDcliente", query = "SELECT f FROM Factura f WHERE f.iDcliente = :iDcliente"), @NamedQuery(name = "Factura.findByTotal", query = "SELECT f FROM Factura f WHERE f.total = :total"), @NamedQuery(name = "Factura.findByCobrado", query = "SELECT f FROM Factura f WHERE f.cobrado = :cobrado"), @NamedQuery(name = "Factura.findByIrpf", query = "SELECT f FROM Factura f WHERE f.irpf = :irpf"), @NamedQuery(name = "Factura.findByDto", query = "SELECT f FROM Factura f WHERE f.dto = :dto")})
public class Factura implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_factura")
    private Integer iDfactura;
    @Basic(optional = false)
    @Column(name = "Fecha")
    private String fecha;
    @Basic(optional = false)
    @Column(name = "ID_cliente")
    private int iDcliente;
    @Basic(optional = false)
    @Column(name = "Total")
    private float total;
    @Basic(optional = false)
    @Column(name = "Cobrado")
    private boolean cobrado;
    @Column(name = "IRPF")
    private Integer irpf;
    @Column(name = "Dto")
    private Integer dto;

    public Factura() {
    }

    public Factura(Integer iDfactura) {
        this.iDfactura = iDfactura;
    }

    public Factura(String IDfactura, String Fecha, String IDcliente, String Total, String IRPF, String Dto,Boolean Cobrado) {
        Integer a=Integer.parseInt(IDcliente);
        this.iDcliente = a;
        Integer b=Integer.parseInt(IDfactura);
        this.iDfactura = b;
        Integer x=Integer.parseInt(IRPF);
        this.irpf = x;
        Integer x1=Integer.parseInt(Dto);
        this.dto = x1;
        if(Fecha==null || Fecha.equals("")){
            //TODO error
        }else{this.fecha = Fecha;}
        this.cobrado = Cobrado;
    }

    public Factura(Integer iDfactura, String fecha, int iDcliente, float total, boolean cobrado,int irpf,int desc) {
        this.iDfactura = iDfactura;
        this.fecha = fecha;
        this.iDcliente = iDcliente;
        this.total = total;
        this.cobrado = cobrado;
        this.irpf=irpf;
        this.dto=desc;
    }

    public Integer getIDfactura() {
        return iDfactura;
    }

    public void setIDfactura(Integer iDfactura) {
        Integer oldIDfactura = this.iDfactura;
        this.iDfactura = iDfactura;
        changeSupport.firePropertyChange("IDfactura", oldIDfactura, iDfactura);
    }

    public String getFecha() {
        return fecha;
    }

    public void setFecha(String fecha) {
        String oldFecha = this.fecha;
        this.fecha = fecha;
        changeSupport.firePropertyChange("fecha", oldFecha, fecha);
    }

    public int getIDcliente() {
        return iDcliente;
    }

    public void setIDcliente(int iDcliente) {
        int oldIDcliente = this.iDcliente;
        this.iDcliente = iDcliente;
        changeSupport.firePropertyChange("IDcliente", oldIDcliente, iDcliente);
    }

    public float getTotal() {
        return total;
    }

    public void setTotal(float total) {
        float oldTotal = this.total;
        this.total = total;
        changeSupport.firePropertyChange("total", oldTotal, total);
    }

    public boolean getCobrado() {
        return cobrado;
    }

    public void setCobrado(boolean cobrado) {
        boolean oldCobrado = this.cobrado;
        this.cobrado = cobrado;
        changeSupport.firePropertyChange("cobrado", oldCobrado, cobrado);
    }

    public Integer getIrpf() {
        return irpf;
    }

    public void setIrpf(Integer irpf) {
        Integer oldIrpf = this.irpf;
        this.irpf = irpf;
        changeSupport.firePropertyChange("irpf", oldIrpf, irpf);
    }

    public Integer getDto() {
        return dto;
    }

    public void setDto(Integer dto) {
        Integer oldDto = this.dto;
        this.dto = dto;
        changeSupport.firePropertyChange("dto", oldDto, dto);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iDfactura != null ? iDfactura.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Factura)) {
            return false;
        }
        Factura other = (Factura) object;
        if ((this.iDfactura == null && other.iDfactura != null) || (this.iDfactura != null && !this.iDfactura.equals(other.iDfactura))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "laboratorio.Factura[iDfactura=" + iDfactura + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
